/**
 * @author MIAO
 * Created on 2011-10-31
 * For more information, please visit:ismiao.com
 */
package com.ismiao.spring.jdbcTemplate;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class TestStatement {
	public static void main(String[] args) throws Exception {
		String userID = javax.swing.JOptionPane.showInputDialog(null, "输入客户号");
		String userName = javax.swing.JOptionPane.showInputDialog(null,
				"输入客户姓名");
		Class.forName("com.mysql.jdbc.Driver");
		Connection conn = DriverManager
				.getConnection("jdbc:mysql://localhost:3306/test","root","root");
		Statement stat = conn.createStatement();
		String sql = "INSERT INTO users(userID,userName) VALUES('" + userID
				+ "','" + userName + "')";
		int i = stat.executeUpdate(sql);
		System.out.println("成功添加" + i + "行");
		stat.close();
		conn.close();
	}
}
